package com.IR.user.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.IR.oss.util.MyDateProcessor;
import com.IR.shop.po.Music;
import com.IR.user.service.BMusicBiz;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;

@Controller
public class BMusicAction {
	@Resource
	private BMusicBiz biz;
	private List<Music> list;
	private Music music;
	
	public List<Music> getList() {
		return list;
	}

	public void setList(List<Music> list) {
		this.list = list;
	}

	public Music getMusic() {
		return music;
	}

	public void setMusic(Music music) {
		this.music = music;
	}

	@RequestMapping(value="showMusic.do")
	public void showMusic(HttpServletRequest request,HttpServletResponse response) throws IOException {
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setCharacterEncoding("utf-8");
		list=biz.showMusic();
		PrintWriter out = response.getWriter();
		MyDateProcessor mydate=new MyDateProcessor();
		JsonConfig config=new JsonConfig();
		config.registerJsonValueProcessor("musicdate", mydate);
		String str=JSONArray.fromObject(list,config).toString();
		out.println(str);
	}
}
